package com.esiran.payadmin.shiro.realm;

import com.esiran.payadmin.shiro.token.MultipleRealmToken;
import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.realm.AuthorizingRealm;
import org.springframework.util.StringUtils;

public abstract class MultipleBaseRealm extends AuthorizingRealm {
    @Override
    public boolean supports(AuthenticationToken token) {
        if(!(token instanceof MultipleRealmToken)){
            return false;
        }
        if (StringUtils.isEmpty(realmName())){
            return false;
        }
        return realmName().equals(((MultipleRealmToken) token).getRealmName());
    }
    public abstract String realmName();
}
